<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    function ajax(options) {
        return new Promise(function (resolve) {
            var xhr = new XMLHttpRequest();
            xhr.open(options.method, options.url)
            xhr.open();
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4 && /^2\d{2}/.test(xhr.status)) {
                    resolve(xhr.responseText)
                }
            }
        })
    }
    ajax({
            method: "GET",
            url: "./test.txt"
        })
        .then(function (res) {
            console.log("数据加载结束", res)
        })
</script>